home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
util
/
boot
/
RA_USCleaner.lha
/
USCleaner
next >
Wrap
Text File
|
2000-04-11
|
14KB
|
516 lines
/*
$VER: RA_USCleaner v1.1 (11.4.2000) © by Nils Görs
known bugs:
- It is not possible to display "" in the textfield gadget correctly.
This script needs the rexxtricks.library
*/
UserStartup = "S:User-Startup" /* which textfile should be used? */
QuickEnd = "YES" /* quit program with [ESC] (YES|NO) */
HorizLine = "YES" /* use horizontal line in liestview (YES|NO) ? */
/* window dimension */
TopNum = 0
LeftNum = 0
HeightNum = 200
WidthNum = 600
windowPos = "DEFAULT" /* DEFAULT = TopNum/LeftNum/heightNum/WidthNum
fs = fullscreen, cs = centerscreen
tl = topleft, cm = centermouse */
/* Don't change anything under this line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
OPTIONS RESULTS
parse source . . called .
PARSE ARG PubScreen
IF PubScreen = "" THEN PubScreen = "Workbench"
call _InitAll()
call BuildGUI()
Loop:
do while ~eof(ca)
call topipe('tick 50')
in= readln(ca)
/*listviews need five values parsed. For string gadgets you want everything after in2 */
parse var in in1 in2 in3 in4 in5 .
parse var in . . infromstring
/*handle help display delay*/
if delaybub>0 then do
delaybub=delaybub-1
/* if we reach zero display the help bubble*/
if delaybub=0 then do
bubleon=newbub
call topipe('bubble top 'bubx 'left 'buby 'gt "'help.newbub'"')
end
end
SELECT
WHEN (in1='help' & helpon~=0 ) then call bubble(in2)
WHEN in1='arexx' then call RxHost()
WHEN in1='iconify' then call iconify()
WHEN in1='gadget' then call gadget()
/* WHEN in1='menu' then call menu()*/
WHEN in1='close' then EXIT()
WHEN in1='key' then call keystroke()
WHEN in1='cx' then call commodity()
OTHERWISE
NOP
END
END
EXIT
_InitAll:
IF show('P','USCLEANER') then DO
address USCLEANER uniconify
address USCLEANER activate
exit
END
IF ~show('L','rexxsupport.library') THEN
IF ~addlib('rexxsupport.library',0,-30,0) THEN
exit(20)
/* Version check */
ca = "THE"
IF SHOWLIST('H', 'AWNPIPE') THEN res=open(ca,"awnpipe:USC/-2042/xc")
if res ~= 1 then do
requesterdata='`requestchoice "USCleaner Error"
"To use this program you need AWNPipe:*n (Vers 2.42 or newer). " "OK"`'
CALL ShellResult(requesterdata)
exit
end
IF ~SHOW(LIBRARIES,'rexxtricks.library') THEN
IF ~ADDLIB('rexxtricks.library',9,-30,38) THEN
quit('Cannot open rexxtricks.library!',10)
/* Init variables */
TRUE = 1
FALSE = 0
Counter = 0
Entries = ""
changes = 0
NL = '0a'x
delaybub = 0
helpon = 1
schutzbits = RXTR_GETPROTECTION(UserStartup)
IF Schutzbits = "" THEN DO
say UserStartup "not found."
EXIT(5)
END
CALL ReadUserStartup(UserStartup)
CALL GetInhalt(1)
RETURN
ReadUserStartup:
PARSE ARG Filename
IF RXTR_READFILE(Filename,Startup) = 0 THEN EXIT
more = 1
a = 0
c = 1 /* Nummer der Liste */
i = 1
DO WHILE more
nummer1 = RXTR_LSEARCH("#?;BEGIN#?",startup,i,case,pattern)
IF nummer1 = -1 THEN DO
more = 0
ITERATE
END
nummer2 = RXTR_LSEARCH("#?;END#?",startup,nummer1+1,case,pattern)
nummer3 = RXTR_LSEARCH("#?;BEGIN#?",startup,nummer1+1,case,pattern)
IF nummer3 < nummer2 & nummer3 ~=-1 THEN say "END Fehler!" /* BEGIN ohne END */
IF nummer2 = -1 & nummer1 ~= -1 THEN say "END Fehler #2" /* BEGIN ohne END im letzten Eintrag!*/
a = a+1
num=INDEX(startup.nummer1,";BEGIN")
Eintraege.a = SUBSTR(startup.nummer1,num+7) /* Listview mit BEGIN|END Einträgen erstellen */
Eintraege2.a = nummer1 nummer2
Eintraege3.a = Eintraege.a a
i = nummer2+1
END
Eintraege.0 = a /* Anzahl der BEGIN|END Einträge */
Eintraege2.0 = a /* Koordinaten für Eintraege */
Eintraege3.0 = a /* Koordinaten für sortierte Eintraege */
IF Eintraege.0 = 0 THEN DO
say "You don't have 'BEGIN...END' instuctions in your User-Startup."
EXIT()
END
call RXTR_QSORT(Eintraege3,,NOCASE,1," ") /* sortiere Eintraege */
RETURN
GetInhalt:
PARSE ARG Nummer
Nummer1=WORD(Eintraege2.Nummer,1)
Nummer2=WORD(Eintraege2.Nummer,2)
d = 0
DO b = nummer1+1 TO nummer2-1
d = d +1
Inhalt.d = startup.b
END
Inhalt.0 = d
RETURN
BuildGUI:
/* define window */
IF windowpos = "DEFAULT" THEN Winpos = 'top='topNum 'left='leftNum 'width='widthNum 'height='heightNum
ELSE Winpos = windowpos 'width='widthNum 'height='heightNum
call topipe('Title="USCleaner"' winpos 'st="Workbench Screen" Icontitle=USC modify help state iconifygadget sendkeys defaultgadgets SpaceInner SpaceOuter activate ii "'called'" pubscreen='pubscreen)
call topipe('ARexx gt "USCLEANER|uniconify|iconify|quit|activate|front|back"')
call topipe('layout v b=7 gt="Assigns"')
call topipe('layout h si so b=0')
IF HorizLine = "YES" THEN AssignListViewID = topipe('listbrowser lbl="" arrows h v minh 200 weiw=40')
ELSE AssignListViewID = topipe('listbrowser lbl="" arrows minh 200 weiw=40')
help.AssignListViewID = 'Entries with all Assign found in User-Startup.*nYou can use cursor keys and Home/End to scroll*nthrough the listview.'
call topipe('WeightBar')
TextEditorID = topipe('textfield arrows h v ro')
help.TextEditorID = 'Contents of selected Assign.'
call topipe('le')
call topipe('layout b=0 h e si so weih 0')
activeGadget = topipe('button gt "_activate" weiw 0 ')
help.activeGadget = 'Select all entries.'
deactiveGadget = topipe('button gt "_deactivate" weiw 0 ')
help.deactiveGadget = 'Deselect all entries.'
ToggleGadget = topipe('button gt "_Toggle" weiw 0 ')
help.ToggleGadget = 'Toggle state of entries.'
RemoveGadget = topipe('button gt "_Remove" weiw 0 ')
help.RemoveGadget = 'Removes the currently selected assign.'
call topipe('le')
call topipe('layout b=0 v si so weih 0')
call topipe('button b=7 minh 2')
call topipe('layout b=0 h si so weih 0')
SaveGadget = topipe('button gt "_Save" weiw 0 ')
help.SaveGadget = 'Saves the changed User-Startup.'
CancelGadget = topipe('button gt "_Cancel" weiw 0 ')
help.CancelGadget = 'Nothing will be changed.'
call topipe('le')
call topipe('le')
call topipe('le')
call topipe('commodity cxname USCleaner cxtitle="USCleaner (c) by Nils Görs" cxdesc="Toggle, removes BEGIN/END instructions" unique cxhotkey="ctrl alt u"')
/*open the GUI window*/
call topipe("open")
/* fill Listview and Textgadget */
call getListView()
RETURN
getListView:
call topipe('id 'AssignListViewID 'list 0')
do i = 1 to Eintraege3.0
Anz=WORDS(Eintraege3.i)
Nodegt=SUBWORD(Eintraege3.i,1,Anz-1)
Node_ID = topipe('id 'AssignListViewID 'addnode gt "'NodeGT'"')
Counter = Counter + 1
Entries = Entries Node_ID
end
call topipe('id 'AssignListViewID 'list 1')
RETURN
getTextview:
PARSE ARG nummer
Anz=WORDS(Eintraege3.Nummer)
Nummer=DELWORD(Eintraege3.Nummer,1,Anz-1)
call GetInhalt(Nummer)
IF Inhalt.0 ~= 0 THEN DO
meinInhalt = ""
do i = 1 to Inhalt.0
IF Index(Inhalt.i,'"') ~= 0 THEN
Inhalt2 = COMPRESS(Inhalt.i,'"')
ELSE
Inhalt2 = Inhalt.i
meinInhalt = meinInhalt||Inhalt2||"*N"
end
call topipe('id' TextEditorID 'gt="'meinInhalt'"')
END
RETURN(Nummer)
topipe:
/* this routine does error checking on lines written to pipe.*/
/*get line to output*/
parse arg out
/* write to the pipe*/
call writeln(ca,out)
/*get responce and parse it.*/
in=readln(ca)
parse var in res1 res2 .
/* if all is ok return the second part of the responce (usualy the GID)*/
if res1='ok' then return(res2)
/* something went wrong, we notify the user then exit */
/*show problem line and responce (reponce may be just a blank line)*/
say 'error from: 'out
say ' responce: ' in
exit
topipe2:
/* this routine does error checking on lines written to pipe.*/
/*get line to output*/
parse arg out
/* write to the pipe*/
call writeln(ca,out)
/*get responce and parse it.*/
in=readln(ca)
parse var in res1 res2 .
return(res1)
ShellResult:
PARSE ARG ShellCmd
cmdid='req'pragma('id')
address command 'rxset' cmdid Shellcmd
from_Shell=getclip(cmdid)
call setclip(cmdid,'')
RETURN(from_Shell)
/*
*** actions
*/
iconify:
IF ARG(1) ~= "" THEN in2 = ARG(1)
IF in2=1 THEN call topipe('id 0 s 32') /* iconify */
ELSE call topipe('id 0 s 64') /* uniconify */
RETURN
/* my very own commodity */
commodity:
SELECT
WHEN in2='show' then call iconify(0)
WHEN in2='hide' then call iconify(1)
WHEN in2='kill' then EXIT
WHEN in2='hotkey' then call iconify(0)
OTHERWISE
END
RETURN
/*
my very personal ARexx host
*/
RxHost:
call topipe2("rc 0")
SELECT
WHEN in2 = 0 THEN call topipe('id 0 s 64') /* uniconify */
WHEN in2 = 1 THEN call topipe('id 0 s 32') /* iconify */
WHEN in2 = 2 THEN EXIT(0) /* quit */
WHEN in2 = 3 THEN call topipe('id 0 s 1') /* activate */
WHEN in2 = 4 THEN call topipe('id 0 s 2') /* window to front */
WHEN in2 = 5 THEN call topipe('id 0 s 4') /* window to back */
OTHERWISE
call topipe2("rc 5")
END
RETURN
gadget:
SELECT
WHEN in2 = activeGadget THEN DO
IF currentnode = "CURRENTNODE" THEN RETURN
counter = FIND(entries,currentnode)
Anz=WORDS(Eintraege3.counter)
Nummer=DELWORD(Eintraege3.counter,1,Anz-1)
Nummer1=WORD(Eintraege2.Nummer,1)
Nummer2=WORD(Eintraege2.Nummer,2)
DO i = Nummer1+1 TO Nummer2-1
IF INDEX(startup.i,";") = 1 THEN startup.i = DELSTR(startup.i,1,1)
END
CALL GetInhalt(counter)
call getTextview(counter)
changes = 1
END
WHEN in2 = deactiveGadget THEN DO
IF currentnode = "CURRENTNODE" THEN RETURN
counter = FIND(entries,currentnode)
Anz=WORDS(Eintraege3.counter)
Nummer=DELWORD(Eintraege3.counter,1,Anz-1)
Nummer1=WORD(Eintraege2.Nummer,1)
Nummer2=WORD(Eintraege2.Nummer,2)
DO i = Nummer1+1 TO Nummer2-1
IF INDEX(startup.i,";") ~= 1 THEN IF startup.i ~= "" THEN startup.i = ";"||startup.i
END
CALL GetInhalt(counter)
call getTextview(counter)
changes = 1
END
WHEN in2 = ToggleGadget THEN DO
IF currentnode = "CURRENTNODE" THEN RETURN
counter = FIND(entries,currentnode)
Anz=WORDS(Eintraege3.counter)
Nummer=DELWORD(Eintraege3.counter,1,Anz-1)
Nummer1=WORD(Eintraege2.Nummer,1)
Nummer2=WORD(Eintraege2.Nummer,2)
DO i = Nummer1+1 TO Nummer2-1
IF INDEX(startup.i,";") = 1 THEN startup.i = DELSTR(startup.i,1,1)
ELSE IF startup.i ~= "" THEN startup.i = ";"||startup.i
END
CALL GetInhalt(counter)
call getTextview(counter)
changes = 1
END
WHEN in2 = RemoveGadget THEN DO
IF currentnode = "CURRENTNODE" THEN RETURN
call topipe('id 0 s 256')
counter = FIND(entries,currentnode)
Anz=WORDS(Eintraege3.counter)
Nummer=DELWORD(Eintraege3.counter,1,Anz-1)
Nummer1=WORD(Eintraege2.Nummer,1)
Nummer2=WORD(Eintraege2.Nummer,2)+1
CALL RXTR_STEMREMOVE(startup,nummer1,nummer2-nummer1)
CALL RXTR_STEMREMOVE(Eintraege,counter,1)
CALL RXTR_STEMREMOVE(Eintraege2,counter,1)
Tempname = "T:USCleaner"
CALL RXTR_WRITEFILE(tempname,startup)
CALL ReadUserStartup(Tempname)
CALL GetInhalt(counter)
call topipe('id' TextEditorID 'gt=""')
IF counter >0 THEN DO
call topipe('id' AssignListViewID 'removenode')
entries = ""
counter = 0
END
call getListView
call topipe2('id 'AssignListViewID 'read')
IF WORD(in,3) ~= 0 THEN DO
CurrentNode = WORD(in,3)
counter = FIND(entries,currentnode)
call getTextview(counter)
END
changes = 1
ADDRESS COMMAND "Delete" Tempname "QUIET"
call topipe('id 0 s 512')
END
WHEN in2 = CancelGadget THEN EXIT(0)
WHEN in2 = SaveGadget THEN DO
IF changes = 1 THEN DO
call topipe('id 0 s 256')
requesterdata='`requestchoice "USCleaner Message"
"Save changed user-startup?" "Yes|No"`'
CALL ShellResult(requesterdata)
IF result = 1 THEN DO
CALL RXTR_WRITEFILE(UserStartup,startup)
CALL RXTR_SETPROTECTION(UserStartup,schutzbits)
Changes = 0
END
call topipe('id 0 s 512')
END
END
WHEN in2 = AssignListViewID THEN DO
currentnode=in5 /* remember the curently selected node for future use...*/
counter = FIND(entries,currentnode)
CALL GetInhalt(counter)
call getTextview(counter)
END
OTHERWISE
NOP
END
RETURN
keystroke:
SELECT
WHEN in2 = 69 THEN IF quickend = "YES" THEN EXIT()
WHEN in2 = 76 | in2 = 62 THEN DO
call topipe('id 'AssignListViewID 'up') /* Cursor up, NUM 8 */
call topipe2('id 'AssignListViewID 'read')
IF WORD(in,3) ~= 0 THEN DO
CurrentNode = WORD(in,3)
counter = FIND(entries,currentnode)
call getTextview(counter)
END
END
WHEN in2 = 77 | in2 = 30 THEN DO
call topipe('id 'AssignListViewID 'down') /* Cursor down, NUM 2 */
call topipe2('id 'AssignListViewID 'read')
IF WORD(in,3) ~= 0 THEN DO
CurrentNode = WORD(in,3)
counter = FIND(entries,currentnode)
call getTextview(counter)
END
END
WHEN in2 = 61 THEN DO /* Home */
call topipe2('id' AssignListViewID 'read')
check = WORD(in,3)
LPos=WORD(entries,1)
IF Lpos ~= check THEN DO
call topipe('id' AssignListViewID 's' lpos)
currentnode = LPos
counter = FIND(entries,currentnode)
call getTextview(counter)
END
END
WHEN in2 = 29 THEN DO /* End */
call topipe2('id' AssignListViewID 'read')
check = WORD(in,3)
LPos=WORD(entries,WORDS(entries))
IF Lpos ~= check THEN DO
call topipe('id' AssignListViewID 's' lpos)
currentnode = LPos
counter = FIND(entries,currentnode)
call getTextview(counter)
END
END
OTHERWISE
NOP
END
RETURN
bubble:
/* get help gadget number*/
newbub=arg(1)
if newbub=-1 then newbub=0
/* return if it has not changed*/
if (bubbleon=newbub) then return()
/* close old bubble if we have one*/
if bubbleon~=0 then call topipe('bubble')
/* if its not a valid gadget kill count down to display*/
if newbub=0 then delaybub=0
/*else remeber mouse position and start new countdown*/
else do
bubx=in3
buby=in4
delaybub=3
end
return